package com.fare.taluo.util.excel.engine.module;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
/**
 * @author keman 项目二部-信息化应用中心-广东数据通信网络有限公司. 
 * @version version, 2007-11-23 下午03:55:40
 * @since from version 1.1
 * 
 */
public class PropertyModel {
	
	/**数据对象中的属性名*/
	private String name;
	
	/**列宽*/
	private String columnWith="10";
	
	/**合并的行数和列数 格式： "rowNumber:1;colNumber:1" 合并两行三列 */
	private String merge = "rowNumber:1;colNumber:1";
	private Map<String,Integer> mergeMap = new HashMap<String,Integer>();
	
	/**数据对象中的属性类型*/
	private String type;
	
	private String format;
	
	/**根据此属性判断此行是否显示*/
	private String displayRow;
	/**根据此属性判断此列是否显示*/
	private String displayCol;
	
	/**显示的表头的名称*/
	private String title;
	
	/**用于设置表头单元格的格式*/
	private String headerStyle;
	private Map<String,String>  headerStyleMap=new HashMap<String,String>();
	
	/**用于设置表中数据单元格的格式*/
	private String dataStyle;
	private Map<String,String>  dataStyleMap=new HashMap<String,String>();
	
	/**为实excel的个性化显示而引信的规则 格式为："class:xx.xxx.xxx;para1:value1;para2:value2" */
	private String regular;
	private Map<String,String> reguarMap = new HashMap<String,String>();

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getColumnWith() {
		return columnWith;
	}
	
	public int getColumnWithInt() {
		if(StringUtils.isNumeric(columnWith)){
		return	Integer.parseInt(columnWith);
		}
		return 10;
	}


	public void setColumnWith(String columnWith) {
		this.columnWith = columnWith;
	}

	public String getMerge() {
		return merge;
	}

	public void setMerge(String merge) {
		if(StringUtils.isNotEmpty(merge) ){
			this.merge = merge;
		}
		String[] strs=this.merge.split(";");
		for(String s: strs){
			String[] temp =s.split(":");
			mergeMap.put(temp[0].toLowerCase(), Integer.valueOf(temp[1]));
		}
	}
	
	public int getMergeColumnNumber() {
		return mergeMap.get("colnumber");
	}
	
	public int getMergeRowNumber(){
		return mergeMap.get("rownumber");
	}
	
	public static void main(String[] s){
		PropertyModel p = new PropertyModel();
	}

	public Map<String, Integer> getMergeMap() {
		return mergeMap;
	}

	public void setMergeMap(Map<String, Integer> mergeMap) {
		this.mergeMap = mergeMap;
	}

	public String getHeaderStyle() {
		return headerStyle;
	}

	public void setHeaderStyle(String headerStyle) {
		if(StringUtils.isEmpty(headerStyle) ){
			return;
		}
		this.headerStyle = headerStyle;
		this.headerStyleMap = transformStingToMap(headerStyle);
	}

	

	public Map<String, String> getHeaderStyleMap() {
		return headerStyleMap;
	}

	public void setHeaderStyleMap(Map<String, String> headerStyleMap) {
		this.headerStyleMap = headerStyleMap;
	}

	public String getDataStyle() {
		return dataStyle;
	}

	public void setDataStyle(String dataStyle) {
		if(StringUtils.isEmpty(dataStyle) ){
			return;
		}
		this.dataStyle = dataStyle;
		this.dataStyleMap = transformStingToMap(dataStyle);
	}

	public Map<String, String> getDataStyleMap() {
		return dataStyleMap;
	}

	public void setDataStyleMap(Map<String, String> dataStyleMap) {
		this.dataStyleMap = dataStyleMap;
	}

	public String getFormat() {
		return format;
	}

	public void setFormat(String format) {
		this.format = format;
	}

	public String getDisplayRow() {
		return displayRow;
	}

	public void setDisplayRow(String displayRow) {
		this.displayRow = displayRow;
	}

	public String getDisplayCol() {
		return displayCol;
	}

	public void setDisplayCol(String displayCol) {
		this.displayCol = displayCol;
	}

	public String getRegular() {
		return regular;
	}

	public void setRegular(String regular) {
		if(StringUtils.isEmpty(regular) ){
			return;
		}
		this.regular = regular;
		this.reguarMap = transformStingToMap(regular);
		
	}

	public Map<String, String> getReguarMap() {
		return reguarMap;
	}

	public void setReguarMap(Map<String, String> reguarMap) {
		this.reguarMap = reguarMap;
	}
	
	
	private Map<String,String> transformStingToMap(String str){
		Map<String,String> map = new HashMap<String,String>();
		String[] strs=str.split(";");
		for(String s: strs){
			String[] temp =s.split(":");
			map.put(temp[0].toLowerCase(), temp[1]);
		}
		return map;
	}
	
	


}
